#pragma once

#include <imaging.h>

enum EImageFormat
{
  ifNone,
  ifPng,
  ifJpeg,
  ifGif,
  ifBmp
};

class PictureSaver
{
public:
  static EImageFormat GetImageFormat(const TCHAR* sFile);
  static const TCHAR* GetFormatExt(EImageFormat format);

  static bool LoadImageFromFile(IImage** pImage, const TCHAR* sFile);

  static bool SaveImageToFile(IImage* pImage, const TCHAR* sFile, EImageFormat format);
  static bool SaveImageToStream(IImage* pImage, IStream* pStream, EImageFormat format);

  static bool ResizeImage(IImage* pSrcImage, IImage** pDstImage, int& width, int& height, bool fitIfSmaller = false);

  static bool ScaleProportional(UINT uFitToWidth, UINT uFitToHeight, UINT &uWidthToScale, UINT &uHeightToScale);

protected:
  static bool GetEncoder(CLSID& id, EImageFormat format, IImagingFactory* pFactory);
};
